const api = require("../../../utils/api.js");
const app = getApp().globalData;
Page({

  /**
   * 页面的初始数据
   */
  data: {
    paData:[],
    hidden:true
  },
  //获取历史真题数据
  paData:async (that)=>{
    let url = "/study/getUnitlist";
    let userData = wx.getStorageSync("USERDATA");
    let courseInfo = wx.getStorageSync("COURSEINFO");
    let parmas = {
      uid:userData.uid,
      sessionid:userData.sessionid,
      market:app.market,
      courseid:courseInfo.id,
      type:4,
      isPageing :0
    };
    api.sendPostsSync(url,parmas)
    .then(
      value=>{
        that.setData({
          paData:value.unitlist
        });
        
      }
    )
    .catch(
      error=>{console.log("获取历史真题数据失败",error);}
    );
  },
  clickItem:async function(options){
    let that = this;
    let option = {
      unitid:options.currentTarget.dataset.res.unitid
    };
    let hidden = await api.clickItem(option);
    that.setData({
      hidden:hidden
    });
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    let that = this;
    //获取初始化数据
    that.paData(that);
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})